<?php

namespace App\Controllers;

use App\Repos\AdministratorsRepos;
use JsonLowCode\Menu;
use Library\App;

class Admin
{
    public function __construct(App $app){

    }

    public function index(AdministratorsRepos $administratorsRepos){

        $model = $administratorsRepos->find(1);
//        if ($model){
//            $model->name = "方法滴滴滴反反复复";
//            $administratorRepos->update();
//        }
//        Logger::make()->logger()->info("ces");

//        dump($model);
//        $result = DB::table(Administrator::class)->select("e.id,e.name")->toResult();
//        dump($result);
//        $repository->
        $list = $administratorsRepos->findAll();
//        dump($list);
//        $list = $administratorRepos->query("a",fn (QueryBuilder $query) => $query->select("a")->where("a.id = :aid")->setParameter("aid",1));
//        dump($list);


//        Administrator::make()->createResultSetMappingBuilder('a')->
//        $list = Administrator::make()->createQueryBuilder("a")->select("a.id,a.name")->orderBy("a.id");
//
//        dump($list);
//        dump($list->getQuery()->getResult());
//
//        dump("index");
        return response()->success("ok",[
            'model'=>$model,
            'list'=>$list
        ]);
    }

    public function index1(){
        dump("index1");
    }
}